<template>
	<view class="content" v-if="beforeloading">
		<view class="me-center" v-if="orderList.length">
			<view class="list-tab">
				<ul class="item-ul" v-for="(item, index) in orderList" :key="index">
					<li>
						<view  class="item-top">
							<view>
								<!-- <text>{{searchVal.Mold==0?'浏览时间':'收藏时间'}}：</text> -->
								<text>{{item.time}}</text>
							</view>
							<view class="pay-type" >
								<text>{{allList[item.odStatus].name}}</text>
							</view>
						</view>
						<u-line dashed></u-line>
						<view class="item-content">
							<view  class="item-left">
								<u-image :src="item.image.split(',')[0]" :fade="true" radius="5"
									width="140" height="140" duration="450"></u-image>
							</view>
							<view class="item-right"  @click="goDetail(item)">
								<view class="item-right-v1">
									<text class="item-title">{{item.name}}</text>
								</view>
								<!-- <view class="item-right-v1 induce">
									<text class="rate-text1">订单地址：{{item.odAddress}}</text>
								</view>
								<view class="item-right-v1 induce">
									<text class="rate-text1">下单时间：{{item.odTime}}</text>
								</view> -->
								<view class="item-right-v2">
									<view class="v2-fh">￥<text class="v2-price">{{item.price}}</text></view>
								</view>
							</view>
						</view>
						
						<u-line dashed></u-line>
						<view class="item-btom">
							<view  @click="cancelClick(item)">
								<view class="item-btom-btn bg-blue-light Mainbtn text-white text-center">删除</view>
							</view>
						</view>
					</li>
				</ul>
				<u-loadmore :status="totalstatus"></u-loadmore>
			</view>
		</view>
		<view class="" v-else>
			<u-empty :text="searchVal.Mold?'暂无收藏':'暂无足迹'" iconSize="200" :mode="searchVal.Mold?'favor':'history'"  class="flex justify-center align-center">
				<!-- <u-button slot="bottom" size="medium" type="primary" text="确定" style="margin:0 30upx;"
					@click="$u.route('/pages/good/goodsList/goodsList');">
					随便逛逛
				</u-button> -->
			</u-empty>
		</view>
	</view>
	<u-empty text="暂无数据" iconSize="200" mode="data" class="flex justify-center align-center" v-else>
		<!-- <u-button slot="bottom" size="medium" type="primary" text="确定" style="margin:0 30upx;"
			@click="$u.route('/pages/good/goodsList/goodsList');">
			随便逛逛
		</u-button> -->
	</u-empty>
</template>
<script>
	export default {
		data() {
			return {
				tabsIndex: 0,
				beforeloading:false,
				searchVal: {
					pageIndex: 1,
					pageSize: 10,
					Mold:1,
					sorting: 'CreationTime desc',
				},
				orderList: [],
				total:0,
				totalstatus: 'nomore',
			}
		},
		onLoad(e) {
			this.searchVal.Mold=Number(e.type)
			this.tabsIndex=Number(e.type)==1?0:1
			uni.setNavigationBarTitle({
				title:e.type==1?'我的收藏':'历史足迹'
			})
			this.getData()
		},
		onPullDownRefresh() {
			this.searchVal.pageIndex = 1
			this.getData()
		},
		onReachBottom(){
			if(this.total<=this.orderList.length){
				this.totalstatus = 'nomore'
			}else {
				this.searchVal.pageIndex += 1
				this.getData()
			}
			
		},
		methods: {
			tabClick(item){
				this.tabsIndex = item
				this.searchVal.Mold=this.allList[this.tabsIndex].tabId
				this.getData()
			},
			getStatusClass(status) {
			    return {
			        'status-red': status == 1,
					'status-2': status == 2,
			        'status-green': status == 3,
			    };
			},

			getData(){
				this.totalstatus="loading"
				this.$ajax.GetHistory(this.searchVal).then(res=>{
					this.total=res.total
					if(res.data==[]){
						this.orderList=[]
						this.totalstatus = 'nomore'
					}else {
						this.orderList=this.searchVal.pageIndex==1?[...res.data]:[...this.orderList, ...res.data],
						this.totalstatus = 'loadmore'
					}
					if(this.orderList.length==this.total){
						this.totalstatus = 'nomore'
					}
					this.beforeloading=true
					uni.stopPullDownRefresh()
				})
			},
				
			// 取消
			cancelClick(item){
				uni.showModal({
					title: '温馨提示',
					content: `确定要取消该${this.searchVal.Mold==0?'足迹':'收藏'}吗？`,
					cancelText: '取消',
					confirmText: '确定',
					success: (res=> {
						if(res.confirm){
							this.$ajax.HistoryDelete({Ids:item.id}).then(res1=>{
								this.$apis.msg('操作成功')
								this.getData()
							})
						}
					})
				})
			},
			
			payClick(item){
				console.log("item===支付====",item)
			},
			evaluateClick(item){
				uni.navigateTo({
					url: '../order/OrderEvaluate?detailDate=' + encodeURIComponent(JSON.stringify(item))
				});
			},
			
		}
	};
</script>
<style scoped lang="scss">
	page {
		text-align: center;
		background-color: #F7F8FA;
	}
	
	.content{
		display: flex;
		flex-direction: column;
		height: 100%;
	}
	.me-head{
		width: 100%;
		height: 80upx;
		padding-bottom: 20upx;
	}
	
	.me-center{
		flex: 1;
		overflow-y: auto;
		width: 100%;
		margin-top: 20upx;
		
		.pullScrollView {
			display: flex;
			flex-direction: column;
		}
		
		.list-tab{
			width: 93%;
			margin: 0 auto;

			.item-ul{
				margin-bottom: 20upx;
			}
			.item-ul li{
				background-color: #ffffff;
				border-radius: 15upx;
				box-shadow: 0 0upx 6upx 0upx rgba(0, 0, 150, .2);
			}
			
			.item-top{
				display: flex;
				justify-content: space-between;
				padding: 20rpx;
				font-size: 28rpx;
				
				.pay-type{
					font-weight: bold;
				}
				.status-red{
					color: #ff5500;
				}
				.status-2{
					color: #4891d9;
				}
				.status-green{
					color: #00d500;
				}
			}
			.item-content{
				display: flex;
				justify-content: center;
				align-items: center;
				padding: 10upx 20upx;
			}
			
			.item-right{
				flex: 1;
				margin-left: 20upx;
				
				.item-right-v1{
					width: 100%;
					padding: 8rpx 0;

					.item-title{
						font-weight: bold;
						display: -webkit-box;
					}
				}
				
				.induce{
					display: flex;
					align-items: center;
					
					.rate-text1{
						font-size: 26rpx;
					}
					.rate-text2{
						margin-left: 20rpx;
						font-size: 26rpx;
						color: #B9B9B9;
					}
				}
		
				.item-right-v2{
					padding: 8rpx 0;
					display: flex;
					justify-content: space-between;
					color: #a3a3a3;
					font-size: 26upx;
					
					.v2-fh{
						color: #ff5500;
						font-size: 22upx;
					}
					.v2-price{
						color: #ff5500;
						font-weight: bold;
						font-size: 32upx;
					}
				}
			}	
			
			.item-btom{
				display: flex;
				justify-content: flex-end;
				padding: 20rpx 10upx;
				font-size: 28upx;
				
				.item-btom-btn{
					padding: 6upx 40upx ;
					border: 1px solid #d2d3d4;
					border-radius: 40upx;
					margin-right: 20upx;
					align-items: center;
				}
				.pay{
					background-color: #07BCAD;
					border: 1px solid #07BCAD;
					color: #ffffff;
				}
			}
		}
	}
</style>
